import request from '../index';

/**
 * 获取打印机列表
 * **/
export const getPrinterList = () => {
    const requestInstance = request.instance;
    return requestInstance.get('/printer');
};

/**
 * 设置打印机的默认配置
 * **/
export const setDefaultConfig = (data: { printer: string }) => {
    const requestInstance = request.instance;
    return requestInstance.put('/printer/config', data);
};

/**
 * 打印文件
 * **/
export const printFile = (data: unknown) => {
    const requestInstance = request.instance;
    return requestInstance.post('/printer', data);
};

/**
 * 清除缓存
 * **/
export const cleanCache = () => {
    const requestInstance = request.instance;
    return requestInstance.delete('/system/cache/clean');
};

/**
 * 获取打印记录
 * **/
export const getRecord = (params: unknown) => {
    const requestInstance = request.instance;
    return requestInstance.get('/printer/record', { params });
};

/**
 * 获取缓存目录地址
 * **/
export const getCachePath = () => {
    const requestInstance = request.instance;
    return requestInstance.get('/system/cache/dir');
};

/**
 * 获取支持打印的文件类型
 * **/
export const getSupportPrintType = () => {
    const requestInstance = request.instance;
    return requestInstance.get('/printer/file/type');
};
